package com.zjf.carpark.controller;


import com.zjf.carpark.entities.TOrder;
import com.zjf.carpark.service.TOrderService;
import com.zjf.carpark.utils.Page;
import com.zjf.carpark.utils.ResponseData;
import com.zjf.carpark.vo.TOrderRequestVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;

import static com.zjf.carpark.utils.CodeAndMessage.CODE200;
import static com.zjf.carpark.utils.CodeAndMessage.SUCCESS;

/**
 * (TOrder)表控制层
 *
 * @author makejava
 * @since 2020-05-13 20:26:10
 */
@RestController
@RequestMapping("tOrder")
public class TOrderController {
    /**
     * 服务对象
     */
    @Resource
    private TOrderService tOrderService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TOrder selectOne(String id) {
        return this.tOrderService.queryById(id);
    }

    /**
     * 分页查询订单
     *
     * @param tOrder
     * @return
     */
    @PostMapping("selectByPage")
    public ResponseData selectByPage(@RequestBody TOrder tOrder) {
        ResponseData responseData = new ResponseData(CODE200, SUCCESS);
        responseData.setCount(tOrderService.count(tOrder));
        responseData.putDataValue("orders", tOrderService.queryAll(tOrder));
        return responseData;
    }
}